#!/bin/bash


PATH=/usr/local/python27/bin;$PATH
export PATH
virtualenv_name="dev_env"
virtualenv_dir="../../dev_env"

install_setuptools(){
        if [ ! -f "$(type easy_install|awk '{print $3}')" ];then
            wget https://bootstrap.pypa.io/ez_setup.py -O - | python
        fi
}


install_pip(){
    if [ ! -f "$(type pip|awk '{print $3}')" ];then install_pip;fi
}

install_virtualenv(){
    install_pip
    if [ ! -f "$(type virtualenv|awk '{print $3}')" ];then
            pip install virtualenv
    fi
}

init_dev_env(){
        Now_Direcroty=$(dirname $0)
        cd $Now_Direcroty;cd ../
        virtualenv $virtualenv_name
}


active_env(){
        echo "run: source ../$virtualenv_name/bin/activate"
}


cd $(dirname $0)
if [ -d $virtualenv_dir ];then
        active_env
else
        install_setuptools
        install_pip
        install_virtualenv
        init_dev_env
        active_env
fi




